#include<bits/stdc++.h>
#define int long long
#define N 100005
using namespace std;
int T;
int n;
int a[N],s[N],f[N];
int rt;
bool z;
vector<int> g[N];
void dfs(int x,int fa){
	s[x]=0;
	if(g[x].size()==1&&x!=rt){s[x]=a[x];return;}
	int w=0;
	for(int i:g[x]){
		if(i==fa) continue;
		dfs(i,x);
		w+=s[i]*s[x];
		s[x]+=s[i];
	}
	a[x]-=s[x];
	if(a[x]>0) z=0;
	if(a[x]<0){
		if(a[x]+w<0) z=0;
		s[x]+=a[x]*2;
		a[x]=0;
	}
}
void sol(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1,u,v;i<n;i++){
		scanf("%lld %lld",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	z=1;
	rt=1;
	for(int i=1;i<=n;i++) if(g[i].size()==1) rt=i;
	dfs(rt,0);
	if(z) printf("YES\n");
	else printf("NO\n"); 
	for(int i=1;i<=n;i++) g[i].clear();
}
signed main(){
	freopen("clean.in","r",stdin);
	freopen("clean.out","w",stdout);
	scanf("%lld",&T);
	while(T--) sol();
	return 0;
}